#include <fstream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

std::vector<int> build_number(const std::string s)
{
    std::vector<int> a;
    a.resize(s.length(), 0);
    size_t n = a.size();
    for (size_t i = 0; i < n; i++)
        if (isdigit(s[i]))
            a[n - 1 - i] = s[i] - '0';
    return a;
}

std::vector<int> multiply(const std::vector<int>& a, int k)
{
    std::vector<int> c(a.size() + 1);
    int p = 0;
    for (size_t i = 0; i < a.size(); i++)
    {
        c[i] = (a[i] * k + p) % 10;
        p = (a[i] * k + p) / 10;
    }
    if (p > 0)
        c[c.size() - 1] = p;
    if (c.back() == 0)
        c.resize(c.size() - 1);
    return c;
}

int compare(const std::vector<int>& a, const std::vector<int>&b, int s)
{
    int sa = a.size();
    int sb = b.size();

    if (sa != sb + s)
        return (sa - sb - s);
    int step = sa - 1;
    while (step >= s && b[step - s] == a[step])
        step--;
    if (step == s - 1)
        return 0;
    return a[step] - b[step - s];
}

void subtract(std::vector<int>& a, const std::vector<int>& b, int s)
{
    if (compare(a, b, s) < 0)
        return;
    for (size_t i = 0; i < b.size(); i++)
    {
        a[i + s] -= b[i];
        size_t j = i + s;
        while ((j < a.size() - 1) && (a[j] < 0))
        {
            a[j + 1] --;
            a[j] += 10;
            j++;
        }
    }
    size_t step = a.size() - 1;
    while ((step > 0) && (a[step] == 0))
        step--;
    a.resize(step + 1);

}

int find_digit(const std::vector<int>& a, const std::vector<int>& b, int s)
{
    std::vector<int> tmp = b;
    for (int k = 9; k >= 0; k--)
    {
        tmp = multiply(b, k);
        if (compare(a, tmp, s) >= 0)
        {
            tmp.clear();
            return k;
        }
    }
    return 0;
}

void divide(const std::vector<int>& a, const std::vector<int>& b, std::vector<int>& res, std::vector<int>& rem)
{
    if ((b.size() == 1) && (b[0] == 0))
    {
        res.resize(0);
        rem.resize(0);
        return; 
    }    
    int s = a.size() - b.size();     
    int comp = compare(a, b, 0);  
    rem = a;
    if (comp > 0)
    {      
        if (compare(a, b, s) < 0)
            s--;
        res.resize(s + 1);
        while (s >= 0)
        {            
            res[s] = find_digit(rem, b, s);
            std::vector<int> temp = multiply(b, res[s]);
            subtract(rem, temp, s);
            s--;
        }
        return;
    }
    if (comp < 0)   
        res.push_back(0);    
    else
    {
        res.push_back(1);  
        rem.clear();
        rem.push_back(0);
    }

}


std::string get_string(const std::vector<int>& v)
{
    std::string s= "";
    if (v.size() == 0)
        return s;
    int n = v.size() - 1;
    while ((n > 0) && (v[n] == 0))
        n--;
    for (size_t i = n; i > 0; i--)
    {
        char c =  static_cast<char>(v[i] + '0');
        s += c;
    }
    char c =  static_cast<char>(v[0] + '0');
    s += c;
    return s;
}

int main()
{
    std::ifstream in("in.txt");
    std::ofstream out("out.txt");
    std::string s;
    while (in >> s)
    {
        std::vector<int> a = build_number(s);
        in >> s;
        if (s[0] == '0')
        {
            out << "<error>\n\n\n";
            continue;
        }

        std::vector<int> b = build_number(s);

        std::vector<int> res, rem;

        divide(a, b, res, rem);

        out << get_string(res) << std::endl;
        out << get_string(rem) << std::endl;
        out << std::endl;
    }
}